import java.io.*;

/**
 * @author zyj
 * @date 2022年05月30日 15:13
 */
public class OutputStreamWriterDemo {
    public static void main(String[] args) {
        OutputStreamWriter osw = null;
        OutputStream os = null;
        try {
            os = new FileOutputStream("a.txt",true);
            osw = new OutputStreamWriter(os,"gbk");
            osw.write("你好");
            osw.write("\n");
            osw.flush();
        } catch (UnsupportedEncodingException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }finally {
            try {
                osw.close();
                os.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }
}
